﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace HappyTemplate
{
	static class RegexCache
	{
		private static readonly Dictionary<string, Regex> _regexes = new Dictionary<string, Regex>();

		public static Regex GetRegex(string expression)
		{
			Regex regex;
			if(!_regexes.TryGetValue(expression, out regex))
			{
				regex = new Regex(expression);
				_regexes.Add(expression, regex);
			}

			return regex;
		}
	}
}
